//
//  JGWithdrawalRecordController.m
//  JGRider
//
//  Created by 单启志 on 2018/2/1.
//  Copyright © 2018年 ffq. All rights reserved.
//  提现记录

#import "JGWithdrawalRecordController.h"
#import "JGWithdrawalRecordCell.h"
#import "JGWithDrawalRecordApi.h"
@interface JGWithdrawalRecordController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)JGWithDrawalRecordApi *api;
@end

@implementation JGWithdrawalRecordController
static NSString *cellId=@"withdrawalRecordCell";
- (void)viewDidLoad {
    [super viewDidLoad];

    [self configSubViews];
}

-(void)configSubViews{

    self.title=@"提现记录";
    [self.view addSubview:self.tableView];
    [self.tableView.mj_header beginRefreshing];
}

-(void)getNewData{
    [self getDataLoadMore:NO];
    [self.tableView.mj_header endRefreshing];
}
//
-(void)getDataLoadMore:(BOOL)isMore{

    FQWeakSelf(self);
    [self.api withdrawalRecordSuccessBlock:^(id result) {
        [weakself.tableView reloadData];
    } faileBlock:^(id error) {

    }];

}

#pragma mark - tableview delegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return AdaptedHeight(64);
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    JGWithdrawalRecordCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
    //cell.model=self.datas[indexPath.row];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


}

#pragma mark - getter setter
-(UITableView *)tableView{

    if (!_tableView) {

        _tableView =[[UITableView alloc]initWithFrame:CGRectMake(0,self.lmj_navgationBar.height, JGScreenW, JGScreenH-self.lmj_navgationBar.height) style:UITableViewStylePlain];

        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([JGWithdrawalRecordCell class]) bundle:nil] forCellReuseIdentifier:cellId];

        _tableView.showsVerticalScrollIndicator=NO; _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
        _tableView.mj_header=[MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(getNewData)];
        _tableView.delegate=self;
        _tableView.dataSource=self;
    }

    return _tableView;

}

-(JGWithDrawalRecordApi *)api{
    if (!_api) {
        _api=[[JGWithDrawalRecordApi alloc]init];
    }
    return _api;
}

@end
